<template>
  <div ref="rootRef">
    <slot></slot>
  </div>
</template>

<script>

import useScroll from './use-scroll'
import { ref } from 'vue'

export default {
  name: 'Scroll',
  props: {
    click: {
      type: Boolean,
      default: true
    },
    // val = 3: 任何时候都派发 scroll 事件, val = 0, 任何时候都不派发scroll事件
    probeType: {
      type: Number,
      default: 0
    }
  },
  // vue3.0 自定义事件
  emits: ['scroll'],
  setup (props, { emit }) {
    const rootRef = ref(null)

    const { scroll } = useScroll(rootRef, props, emit)

    return {
      rootRef,
      scroll
    }
  }
}
</script>

<style scoped>

</style>
